package thread;

public class DaemonThreadDemo {
    public static void main(String[] args) {
        Thread rose=new Thread("rose"){
            @Override
            public void run() {
                for (int i = 0; i < 5; i++) {
                    System.out.println(getName()+"let me go!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(getName()+"aaaaaaaaaaa--------");
                System.out.println("扑通");
            }
        };
        Thread jack=new Thread("jack"){
            @Override
            public void run() {
                for (int i = 0; i < 5; i++) {
                    System.out.println("you jump  !");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }

            }
        };
        rose.start();
        jack.setDaemon(true);//将Jack设置成守护线程
        jack.start();
        while(true);
    }
}
